<?php

namespace App\Jobs\Log;

use Exception;
use App\Jobs\Job;

class LogAddJob extends Job
{

    protected $data;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        // app('log')->info('日志写入任务执行');

        // 写入日志
        app('logService')->add($this->data);
    }

    /**
     * 任务失败的处理过程
     *
     * @param  Exception  $exception
     * @return void
     */
    public function failed(Exception $exception)
    {
        // 给用户发送任务失败的通知，等等……
        // app('log')->info('日志写入任务失败---');
        // app('log')->info($exception);
    }
}
